<?php
/**
 * Created by PhpStorm.
 * User: Thans
 * Date: 2018/10/18
 * Time: 18:01
 */

namespace app\common\controller\platform;

use app\admin\facade\PlatformWechat;
use Naixiaoxin\ThinkWechat\Facade;

class Wechat
{
    protected $app;

    public function init($id)
    {
        $wechatInfo = PlatformWechat::getById($id);
        if ($wechatInfo['code'] != 1001) {
            return false;
        }
        $config['app_id'] = $wechatInfo['app_id'];
        $config['secret'] = $wechatInfo['app_secret'];
        $config['response_type'] = 'array';
        $config['auth'] = [
            'scopes' => ['snsapi_userinfo'],
            'callback' => '',
        ];
        return Facade::officialAccount('', $config);
    }

}